#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "titlebar.h"
#include "textedit.h"
#include "thread.h"
#include "xml.h"
#include <QMainWindow>
#include <QProgressBar>
#include <QLabel>
#include <QSplitter>

#include <QToolTip>

#define MARGIN 20

#include"pic_model.h"
#include "backlab.h"

class QVBoxLayout;
class QFileDialog;
class QString;
class Button;
class QMouseEvent;
class QLineEdit;
class QTextEdit;
class QHBoxLayout;
class QPoint;
class QDomDocument;
class QComboBox;
class QCheckBox;
class QRadioButton;
class QTimer;
class CLineEdit;
namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    void python_init();

    void createUI_title();
    void createUI_page_front();
    void createUI_page1();
    void createUI_page2();
    void createUI_page3();
    void createUI_page4();
    void createUI_page5();
    void createUI_page_error();
    //void extractdebdata(QString debfile_path, QString  soft_name, QString runPath);
    int  readConf(QString path, QString name);
    
    //xml文件操作
    void read_xml(QString filename);  

//    已由Thread实现
    //生成 control configure and file archive
//    int cpkfilelistgeneration();
    int cpkscriptgeneration();
    void create_desktop(QString filename);
    void delete_debian_and_rmptxt(QString cache_dir);
    int set_script_into_file();
    void delete_data();
    void inputShell(char * shell);
//    void read_fileinfo_to_ui();
    int read_fileinfo_to_ui();
    int write_xml_to_ui();

    void screenshotmodel_loadData();//读取截图信息
    void reset_iconFileName();    //重置图标文件名称
    void reset_screenshotFileName();    //重置截图文件名称
    void icon_loadData();    //读取icon路径信息
    void desktop_loadData();    //读取启动器路径信息


public slots:
    void click_button();
    void click_button_icon();
    void click_button_2();
    void click_button_3();
    void click_button_4();
    void click_button_6();
    void click_button_7();
    void click_button_8();
    void click_button_9();
    void click_button_Generate_Xml();
    void click_button_Undo_Xml();
    void click_button_Generate_Script();
    void click_button_Undo_Script();
    int click_button_Generate_Desktop();
    void click_button_Undo_Desktop();
    void click_btn_package_button();
    void click_btn_transfer_button();
    void click_btnbutton();
    void click_tlbbutton();
    void click_tlb2button();
    void click_previousbutton();
    void click_closebutton();
    void click_minimizebutton();
     void click_helpbutton();
    void click_transbutton();
    void click_btn_selbutton();
    void click_btn_transbutton();
    void click_btn_opendirbutton();
    void click_btn_exec();
    void click_btn_icon();
//    void click_btn_pic();
    void click_btn_desktop();
    void scrollbar_value_changed(int value);
    void set_scrollbar_value_by_dig1();
    void set_scrollbar_value_by_dig2();
    void set_scrollbar_value_by_dig3();
    void set_scrollbar_value_by_dig4();
    void set_scrollbar_value_by_dig5();
    void set_scrollbar_value_by_dig6();
    void slot_get_move_event(QPoint p1,QPoint p2);
    void process_Protocol(int index);
    void button_desktop_Judge(int id);
    void button_patch_Judge(int id);
    void button_essential_Judge(int id);
    void process_Protocol2(int index);
    void button_desktop_Judge2(int id);
    void button_patch_Judge2(int id);
    void button_essential_Judge2(int id);
    void slot_Msg_extract_end();
    void slot_Msg_pack_end(QString errorInfoDes);
    void timeUpDate();
    void timeUpDate2();
    void timeUpDate3();
    void process_type_get(int id);
    void process_terminal_get(int id);
    void process_hidden_get(int id);
    void process_category_get(int id);

    void slot_Msg_error(QString str_Msg_error);//错误对话框
    void slot_Msg_py_end(int thread_type);//py执行成功
    void slot_screenshot_doubleClicked(const QModelIndex index);//截图表双击响应槽
    void slot_screenshot_menu_edit();//截图表菜单-编辑
    void slot_screenshot_menu_del();//截图表菜单-删除
    void slot_screenshot_menu_row_detail(const QModelIndex index);//截图表详细数据
    void slot_screenshot_menu_show(QPoint pos);//截图表菜单显示
    void slot_screenshot_clicked(const QModelIndex index); //截图表单击响应槽

    signals:
    void signal_tips_changed(QString tips);
    void signal_Msg_error(QString str_Msg_error);

public:
    Ui::MainWindow *ui;
    QWidget *centerWindow;
    Button* btn;
    Button* tlb,*tlb2;
    Button* dig1;
    Button* dig2;
    Button* dig3;
    Button* dig4;
    Button* dig5;
    Button* dig6;
    Button* btn_package;
    Button* btn_transfer;
    Button* btn_trans;
    Button* btn_opendir;
    QFileDialog *openFilePath;
//    QLabel* label_logo;
    backLab* label_logo;
    QString deb_path;
    QString debfile_path;
    QString extract_path;
    QVBoxLayout *mainLayout ;
    QProgressBar* pgb;
    QLabel*  occupying;
    QSplitter * mainSplitte;
    //QTextEdit* tldesc_en;
    bool m_bLeftButtonPress;
    QPoint m_ptPress;
    QPoint m_ptMove;

    QString runPath;
    QString soft_name;
    QString cache_dir;
    QString version;
    Titlebar* t;
    QHBoxLayout* horizontalLayout_header;
    QLabel * occupying_dig;
#if 0
    QString m_strCategory;
    QString m_strDepends;
    QString m_strDense;
    QString m_strLicense;
    QString m_pack_hp;
    QString m_packname;
    QString m_desc;
    QString m_inst_size;
#endif

#if 0
    QLineEdit* sname_en;
    QLineEdit* sname;
    QComboBox* scategory ;
    QLineEdit* l_1;
    QLineEdit* l_2;
    QLineEdit* l_3;
    QLineEdit* l_4;
    QComboBox* sdenpendence;
    QComboBox* sdense;
    QComboBox* sPriority;
    QComboBox* sProtocol;
    QLineEdit* lExec;
    QLineEdit* larch;
    QLineEdit* lsdesc;
    QLineEdit* lsdesc_en;
    textedit* tldesc;
    QTextEdit* script_edit;
    QCheckBox* root_user,*sudo_user,*ipc_user,* s_n_access,* network_access,* xorg_access,* manager_user,* m_g_user,* variable_system,* manager_device,* m_i_open,
    * manager_app,* setting_system,* conf_change,* c_a_c,* d_u_a_c,* underly_access,* f_c_d,* diagnostic,* dump,* a_d_c,* m_s_c,* b_t_c,* tasks_get,* search_global,
    * p_b_k ,* clear_master,* s_a_m,* f_f_m,* f_u_m,* b_f_r,* s_i_r,* logs_read,* reboot,* c_b_r,* l_p_s,* time_set,* z_t_s,* credentials_use,* h_b_c,* b_h_r,* b_h_w,* s_w_a,
    * s_w_c ,* bluetooth,* manager_bluetooth,* power_device;
    QRadioButton* r_enterprise;
    QRadioButton* r_individual;
    QRadioButton* r_isDesktop;
    QRadioButton* r_isNoDesktop;
    QRadioButton* r_isPatch;
    QRadioButton* r_isNoPatch;
    QRadioButton* r_isEssential;
    QRadioButton* r_isNoEssential;
    QLineEdit* l_name;
    QLineEdit* l_tel;
    QLineEdit* l_pg;
    QLineEdit* l_email;
    QLineEdit* l_desc;
    QLineEdit* l_desc_en;
    QLineEdit * script_line;
    QLineEdit* dir_lineEdit ;
    QLineEdit*  lcategory;
    QLineEdit* lprotocol;
#endif
    CLineEdit * script_line;
    CLineEdit * script_line2;
    QLineEdit* dir_lineEdit ;
    QTextEdit* script_edit, * script_edit2;
    QTimer* timer;
    QTimer* timer2;
    QTimer* timer3;

    Thread *thread_extract;
    Thread * thread_package;
    Thread * thread_package2;
    int count;
    int count2;
    int count3;


    //打包工具所需变量声明
    QString source_Path,target_Path,strQToolButton,strQToolButton2,m_strLicense_2;
    Xml * control_xml_1, *control_xml_2;

    int bFlag_type; //1表示打包,2表示转包
    QLabel* pix_tips;
    QLabel* tips;
    QTextEdit* textEdit_errorInfoDes;
    QLabel* occupying_page_3;
    QLineEdit* l_hp;
    QString str_Source, str_Target;

private:
    void progreddBarEnable(bool y_n);
//    void clearUIData();
};

#endif // MAINWINDOW_H
